<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui" template="ui.xhtml">
	<ui:define name="head">
		<style type="text/css">
.ui-confirm-dialog-severity {
	margin: 0 7px 7px 0;
}
</style>
	</ui:define>
	<ui:define name="content">
		<p:panel header="#{msg.title_storageunits}">
			<h:form>
				<p:commandButton value="#{msg.label_newstorage}"
					onclick="dlgNew.show()" icon="add" />
			</h:form>
			<h:form id="frmNew">
				<p:dialog header="#{msg.label_newstorage}" widgetVar="dlgNew"
					resizable="false" modal="true" id="newDialog">
					<p:growl id="newGlow" showDetail="false" sticky="true" />
					<h:panelGrid columns="2" style="margin-bottom:10px; width: 400px;"
						cellpadding="">
						<h:outputLabel for="name" value="#{msg.label_name}:" />
						<p:inputText id="name" size="30" value="#{StorageBean.name}"
							required="true" />
						<h:outputLabel for="route" value="#{msg.label_route}:" />
						<p:inputText id="route" size="30" value="#{StorageBean.route}" />
						<h:outputLabel for="size" value="#{msg.label_space} (MB):" />
						<p:inputText id="size" size="10" value="#{StorageBean.space}" />
						<h:outputText value="#{msg.label_shared}: " />
						<p:selectOneRadio id="shared" value="#{StorageBean.shared}">
							<f:selectItem itemLabel="Si" itemValue="1" />
							<f:selectItem itemLabel="No" itemValue="0" />
						</p:selectOneRadio>
						<f:facet name="footer">
							<p:commandButton id="submitButton" value="#{msg.label_save}"
								icon="save" actionListener="#{StorageBean.saveStorage}"
								oncomplete="dlgNew.hide(); " update=":frmlist,newGlow :frmNew" />
							<p:commandButton value="#{msg.label_cancel}"
								oncomplete="dlgNew.hide();" icon="cancel" />
						</f:facet>
					</h:panelGrid>
				</p:dialog>
			</h:form>
			<br />
			<!-- Formulario de la lista -->
			<h:form id="frmlist">
				<p:dataTable var="storage" value="#{StorageBean.listStorage}"
					paginator="true" rows="10" paginatorPosition="bottom"
					paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
					rowsPerPageTemplate="1,5,10,15,20,30">
					<h:inputHidden value="#{storage.id}" />
					<p:column headerText="#{msg.label_name}">
						<h:outputText value="#{storage.name}" />
					</p:column>
					<p:column headerText="#{msg.label_route}">
						<h:outputText value="#{storage.route}" />
					</p:column>
					<p:column headerText="#{msg.label_space}">
						<h:outputText value="#{storage.space}" />
					</p:column>
					<p:column headerText="#{msg.label_shared}">
						<h:outputText value="#{storage.share}" />
					</p:column>
					<p:column style="width:12%; text-align: center;">
						<p:commandButton oncomplete="editDialog.show()" icon="edit"
							title="#{msg.label_edit}" update=":frmEdit"
							actionListener="#{StorageBean.prepareStorage(storage.id)}" />
						<p:commandButton icon="delete" title="#{msg.label_delete}"
							onclick="confirmation.show()"
							actionListener="#{StorageBean.prepareStorage(storage.id)}" />
					</p:column>
				</p:dataTable>
			</h:form>
			<!-- Formulario para editar -->
			<h:form id="frmEdit">
				<p:dialog header="#{msg.title_editstorage}" widgetVar="editDialog"
					resizable="false" modal="true" id="editDialog">
					<p:growl id="editGrowl" showDetail="false" sticky="true" />
					<h:panelGrid columns="2" style="margin-bottom:10px; width: 400px;">
						<h:outputLabel for="name" value="#{msg.label_name}:" />
						<p:inputText id="name" size="30" value="#{StorageBean.name}"
							required="true" />
						<h:outputLabel for="route" value="#{msg.label_route}:" />
						<p:inputText id="route" size="30" value="#{StorageBean.route}" />
						<h:outputLabel for="size" value="#{msg.label_space} (MB):" />
						<p:inputText id="size" size="10" value="#{StorageBean.space}" />
						<h:outputText value="#{msg.label_shared}: " />
						<p:selectOneRadio id="shared" value="#{StorageBean.shared}">
							<f:selectItem itemLabel="#{msg.label_yes}" itemValue="true" />
							<f:selectItem itemLabel="#{msg.label_no}" itemValue="false" />
						</p:selectOneRadio>
						<f:facet name="footer">
							<p:commandButton value="#{msg.label_save}" icon="save"
								oncomplete="editDialog.hide();" update=":frmlist,editGrowl"
								actionListener="#{StorageBean.editStorage()}" />
							<p:commandButton value="#{msg.label_cancel}"
								oncomplete="editDialog.hide();" icon="cancel" />
						</f:facet>
					</h:panelGrid>
				</p:dialog>
			</h:form>
			<!-- Formulario para borrar -->
			<h:form prependId="false">
				<p:growl id="deleteGlow" />
				<p:confirmDialog id="confirmDialog"
					message="#{msg.label_confirmationdltsto}"
					header="#{msg.title_deletestorage}" severity="alert"
					widgetVar="confirmation">
					<p:commandButton id="confirm" update=":frmlist,deleteGlow"
						value="#{msg.label_yes}" oncomplete="confirmation.hide()"
						actionListener="#{StorageBean.deleteStorage()}" icon="accept" />
					<p:commandButton id="decline" value="#{msg.label_no}"
						onclick="confirmation.hide()" type="button" icon="cancel" />
				</p:confirmDialog>
			</h:form>
		</p:panel>
		<p:confirmDialog header="Oooops!!!" severity="alert"
			visible="#{not empty param['expired']}" message="View has expired."
			widgetVar="confirmDlg">
			<p:commandButton type="button" value="OK" onclick="confirmDlg.hide()" />
		</p:confirmDialog>
	</ui:define>
</ui:composition>